<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
</head>

<body>

  <div class="page-group">
    <div class="page page-current">

      <header class="bar bar-nav fs-header-small">
        <a onclick="window.history.back();" class="icon icon-left pull-left"></a>
        <h1 class="title">第${batchCourseware.sorting}周课件</h1>
      </header>
      
      <div class="content">
        <div class="buttons-tab">
          <a href="${ctx.host}/rounds/${batchCourseware.courseRound.id}/batch-coursewares?type=${batchCourseware.type}&week=${batchCourseware.sorting}" class="button">动作</a>
          <a href="${ctx.host}/rounds/${batchCourseware.courseRound.id}/batch-coursewares/${batchCourseware.id}/diet" class="active button">饮食</a>
        </div>
        
        <div class="diet-wrap" style="padding-bottom: 2.2rem;">
          <div class="card" style="margin: .5rem 0;">
            <div class="card-header">早餐</div>
            <div class="card-content">
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">早餐 / <small>${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].name}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="breakfast" 
                     data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].id : ''}" 
                     data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].template.id : ''}"
                     style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] ? '' : 'none'}">修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]]}">
                      <a href="javascript:void(0);" class="add-diet-btn set-meal" data-type="breakfast"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="breakfastDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="breakfastDescription" class="diet-description" placeholder="饮食描述">${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div>
              </div>
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">早餐加餐 / <small>${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).name : ''}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                  data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).id : ''}" 
                  data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).template.id : ''}"
                  style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks ? '' : 'none'}">修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks}">
                      <a href="javascript:void(0);" data-type="snack" data-snack="breakfast" class="add-diet-btn set-meal"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="breakfastSnacksDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="breakfastSnacksDescription" class="diet-description" placeholder="饮食描述">${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div> 
              </div>
            </div>
          </div>
          <div class="card" style="margin: .5rem 0;">
            <div class="card-header">午餐</div>
            <div class="card-content">
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">午餐 / <small>${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].name}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="lunch" 
                  data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].id : ''}"
                  data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].template.id : ''}"
                  style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] ? '' : 'none'}">修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]]}">
                      <a href="javascript:void(0);" data-type="lunch" class="add-diet-btn set-meal"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="lunchDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="lunchDescription" class="diet-description" placeholder="饮食描述">${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div>
              </div>
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">午餐加餐 / <small>${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).name : ''}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                  data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).id : ''}"
                  data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).template.id : ''}"
                  style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks ? '' : 'none'}" >修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks}">
                      <a href="javascript:void(0);" data-type="snack" data-snack="lunch" class="add-diet-btn set-meal"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="lunchSnacksDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="lunchSnacksDescription" class="diet-description" placeholder="饮食描述">${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div> 
              </div>
            </div>
          </div>
          <div class="card" style="margin: .5rem 0;">
            <div class="card-header">晚餐</div>
            <div class="card-content">
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">晚餐 / <small>${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].name}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="dinner" 
                    data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].template.id : ''}"
                    data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] ? batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].id : ''}"
                    style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] ? '' : 'none'}">修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]]}">
                      <a href="javascript:void(0);" data-type="dinner" class="add-diet-btn set-meal"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="dinnerDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="dinnerDescription" class="diet-description" placeholder="饮食描述">${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div>
              </div>
              <div class="card-content-inner">
                <div class="action-header">
                  <label class="action-title">晚餐加餐 / <small>${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).name : ''}</small></label>
                  <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                  data-diet="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).id : ''}"
                  data-template="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).template.id : ''}"
                  style="display:${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks ? '' : 'none'}">修改</a>
                </div>
                <div class="action-content">
                  <c:choose>
                    <c:when test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks}">
                      <a href="javascript:void(0);" data-type="snack" data-snack="dinner" class="add-diet-btn set-meal"></a>
                      <div class="intro" style="display:none;">
                        <textarea name="dinnerSnacksDescription" class="diet-description" placeholder="饮食描述"></textarea>
                      </div>
                    </c:when>
                    <c:otherwise>
                      <div class="intro">
                        <textarea name="dinnerSnacksDescription" class="diet-description" placeholder="饮食描述">${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).description}</textarea>
                      </div>
                    </c:otherwise>
                  </c:choose>
                </div> 
              </div>
            </div>
          </div>
          
        </div>
        <a href="javascript:void(0);" class="save-diet button button-fill button-big" style="display: none;">保存修改</a>
      </div>
    </div>  
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/courseware/batch-courseware-diet.js" />
  <script type="text/javascript">
    require(['page/courseware/batch-courseware-diet'], function(page) {
      page.init({
          'roundId': '${batchCourseware.courseRound.id}',
          'batchId': '${batchCourseware.id}',
          'type': '${batchCourseware.type}',
          'breakfasts':JSON.parse('${breakfasts}'),
          'lunchs': JSON.parse('${lunchs}'),
          'dinners': JSON.parse('${dinners}'),
          'snacks': JSON.parse('${snacks}')
      })
    })
  </script>

</body>
</html>